#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QtNetwork>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void find_seralport();
    void find_host_ip();
    char ConvertHexChar(char ch);
    void StringToHex(QString str, QByteArray &senddata); //字符串转换为十六进制数据0-F
private slots:
    void on_openPortBtn_clicked();
     void read_Com();			//手动添加的槽函数声明，用于读出串口缓冲区的内容

     void on_sendButton_clicked();

     void acceptConnection();

     void readClient();
     void readServer();
     void readUdpDatagrams();

     void on_pushButton_Monitor_clicked();

     void on_pushButton_send_clicked();


     void on_pushButton_clicked();

     void on_pushButton_2_clicked();
     void testFunction();

     void on_comboBox_currentIndexChanged(int index);

private:
    Ui::MainWindow *ui;
    QSerialPort serial;			//声明串口类
    QTcpServer *server;
    QTcpSocket *client;
    QUdpSocket *sender;
    QUdpSocket *receiver;
    QTcpSocket *clientConnection[10];
    quint8 index;
    QTimer testTimer;
    quint16 port_old;
    quint16 flag;
    QHostAddress serverAddress;
    QByteArray datagram;
};


#endif // MAINWINDOW_H
